package com.xxx.filter;

import com.xxx.util.BaseContext;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "LoginCheckFilter",urlPatterns = "/*")
public class LoginCheckFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {

        chain.doFilter(request, response);

//        HttpServletRequest req = (HttpServletRequest) request;
//        HttpServletResponse resp = (HttpServletResponse) response;
//
//        String uri = req.getRequestURI();
////        System.out.println(uri);
//        String[] uris = {"/rbac/login/login.html","css","/img","/js","okLogin"};
//
//        for (String s : uris) {
//            if(uri.contains(s)){
//                chain.doFilter(request, response);
//                return;
//            }
//        }
//        Long id = (Long) req.getSession().getAttribute("employeeId");
//        if (null != id){
//            BaseContext.setCurrentId(id);
//            chain.doFilter(request, response);
//        }else {
//            resp.sendRedirect("/rbac/login/login.html");
//        }
//

    }
}
